package linuxbox.resource.servlet;

import javax.servlet.http.*;

import linuxbox.common.*;

public class BoxResourceSettingsAction extends Action
{
	protected static String viewJSP = null;
	protected static String editJSP = null;

  public void doAction(HttpSession aSession, BoxSession aBoxSession,
  HttpServletRequest req, HttpServletResponse resp) throws Exception
  {
    String str = req.getParameter("SubmitCancel");
    if ( str != null )
    {
      sendFile(viewJSP,req,resp);
      return;
    }

    str = (String) req.getParameter("SubmitSave");
    if ( str != null )
    {
      aBoxSession.setConfigInt("resource", "General", "Entries Per Page", Integer.parseInt((req.getParameter("ENTRIES_PER_PAGE"))));
      sendFile(viewJSP,req,resp);
      return;
    }

    str = (String) req.getParameter("SubmitEdit");
    if ( str != null )
    {
      str = aBoxSession.getConfigString("resource", "General", "Entries Per Page");
      if (str == null || str.length() == 0)
        str = "20";
      req.setAttribute("ENTRIES_PER_PAGE", str);
      sendFile(editJSP,req,resp);
      return;
    }
    sendFile(viewJSP,req,resp);
  }

	public void setViewJSP(String str)
	{
		viewJSP = str;
	}
	public void setEditJSP(String str)
	{
		editJSP = str;
	}
}
